package com.kyzh.core.adapters

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.gushenge.core.beans.Deal
import com.gushenge.core.dao.GlobalKeys
import com.kyzh.core.R
import com.kyzh.core.activities.BaseFragmentActivity
import com.kyzh.core.utils.startActivity


class GameDetailDealAdapter(layout: Int, val beans: ArrayList<Deal>) : BaseQuickAdapter<Deal, BaseViewHolder>(layout, beans) {
    override fun convert(helper: BaseViewHolder, item: Deal) {
        item?.let {
            helper.setText(R.id.time,"${context.getString(R.string.addedTime)}: ${it.time}")
                    .setText(R.id.name,it.name)
                    .setText(R.id.content,it.introduction)
                    .setText(R.id.price,"¥${it.money}")

            Glide.with(context).load(it.image).into(helper.getView(R.id.image))
            helper.itemView.setOnClickListener {
                context.startActivity<BaseFragmentActivity>(
                        GlobalKeys.TYPE to BaseFragmentActivity.DEAL_PRODUCT_DETAIL,
                        GlobalKeys.KEY to beans[helper.adapterPosition].id
                )
            }
        }
    }
}